package avicit.bdp.dcs.rule.rest;

import avicit.bdp.dcs.rule.dto.TableRuleDTO;
import avicit.bdp.dcs.rule.service.TableRuleService;
import avicit.platform6.core.rest.msg.ResponseMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-08-06 12:01
 * @类说明：批量修改表名规则接口
 * @修改记录：
 */
@RestController
@RequestMapping("/api/bdp/dcs/rule/TableRuleRest")
@Api(tags = "批量修改表名规则接口")
public class TableRuleRest {

    @Autowired
    private TableRuleService tableRuleService;

    @PostMapping("/saveTableRule")
    @ApiOperation(value = "新增修改表名规则")
    public ResponseMsg<String> saveTableRule(@RequestBody TableRuleDTO tableRuleDTO) throws Exception{
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        responseMsg.setResponseBody(tableRuleService.saveTableRule(tableRuleDTO));
        return responseMsg;
    }

    @DeleteMapping("/deleteTableRuleById")
    @ApiOperation(value = "删除修改表名规则")
    public ResponseMsg<String> deleteTableRuleById(@ApiParam(value = "规则id", name = "tableRuleId", required = true) @RequestParam String tableRuleId) throws Exception{
        ResponseMsg<String> responseMsg = new ResponseMsg<>();
        responseMsg.setResponseBody(tableRuleService.deleteTableRuleById(tableRuleId));
        return responseMsg;
    }

    @GetMapping("/getTableRuleListByJobId")
    @ApiOperation(value = "根据jobId查询修改表名规则")
    public ResponseMsg<List<TableRuleDTO>> getTableRuleListByJobId(@ApiParam(value = "jobId", name = "jobId", required = true) @RequestParam String jobId) throws Exception{
        ResponseMsg<List<TableRuleDTO>> responseMsg = new ResponseMsg<>();
        responseMsg.setResponseBody(tableRuleService.getTableRuleListByJobId(jobId));
        return responseMsg;
    }

}
